package xin.marcher.module.common.enums.inventory;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 库存预警状态枚举
 */
public enum InventoryStatusEnum {

    /**
     * 预警状态
     */
    WARNING_STATUS(1, "预警状态"),
    /**
     * 正常状态
     */
    NORMAL_STATUS(0, "正常状态"),
    ;

    private Integer code;

    private String value;

    InventoryStatusEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (InventoryStatusEnum element : InventoryStatusEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static InventoryStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (InventoryStatusEnum element : InventoryStatusEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }
}